package cn.kust.apiuser.interceptor;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
 * @author WY
 * @data 2022/7/21 10:17
 **/
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Bean
    public JwtInterceptor jwtInterceptor() {
        return new JwtInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(jwtInterceptor())
                // 拦截
                .addPathPatterns("/**")
                // 不拦截
                .excludePathPatterns("/noauth")
                .excludePathPatterns("/api-user/verification-code")
                .excludePathPatterns("/api-user/verification-code-check")
                .excludePathPatterns("/api-user/token-refresh");

    }


}
